package com.tunan.persistence.dao.sck;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.tunan.persistence.model.LsjToken;
import com.tunan.persistence.model.TSysUserLoginTn;

public interface TSysUserLoginTnMapper extends EntityMapper<TSysUserLoginTn> {
	int deleteByPrimaryKey(String dlm);

	int insert(TSysUserLoginTn record);

	int insertSelective(TSysUserLoginTn record);

	TSysUserLoginTn selectByPrimaryKey(String dlm);

	int updateByPrimaryKeySelective(TSysUserLoginTn record);

	int updateByPrimaryKey(TSysUserLoginTn record);

	@Select("SELECT * FROM T_SYS_USER_LOGIN_TN T WHERE ACCESS_TOKEN =  #{token}")
	public TSysUserLoginTn selectByToken(String token);

	@Delete("DEL FROM T_SYS_USER_LOGIN_TN")
	void truncateTable();

	@Update("UPDATE T_SYS_USER_LOGIN_TN T SET DEADLINE = #{deadline} WHERE DLM=#{dlm} ")
	void updateDeadline(TSysUserLoginTn tSysUserLoginTn);

	/**
	 * 
	 * @param calendar
	 * @return List<TSysUserLoginTn>
	 * @Description 查询令牌大于当前时间的用户 
	 * @date 2016年4月4日
	 * @author kinda
	 */
//	@Select("SELECT d.DLM, d.ACCESS_TOKEN, d.DEADLINE, d.CONTENT FROM T_SYS_USER_LOGIN_TN d WHERE DEADLINE >=#{deadline}")
	List<TSysUserLoginTn> selectByDeadline(Date calendar);

	@Delete("DELETE FROM T_SYS_USER_LOGIN_TN WHERE DEADLINE < #{time}")
	void delByDeadline(Date time);


}